home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Brushes and Pens / TwoPointLinearGradientBrush / TwoPointLinearGradientBrush.cs next >
Encoding:
Text File  |  2001-01-15  |  965 b   |  30 lines

  1. //----------------------------------------------------------
  2. // TwoPointLinearGradientBrush.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class TwoPointLinearGradientBrush: PrintableForm
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new TwoPointLinearGradientBrush());
  14.      }
  15.      TwoPointLinearGradientBrush()
  16.      {
  17.           Text = "Two-Point Linear Gradient Brush";
  18.      }
  19.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  20.      {
  21.           LinearGradientBrush lgbrush = 
  22.                new LinearGradientBrush(
  23.                          new Point(cx / 4, cy / 4), 
  24.                          new Point(3 * cx / 4, 3 * cy / 4),
  25.                          Color.White, Color.Black);
  26.  
  27.           grfx.FillRectangle(lgbrush, 0, 0, cx, cy);
  28.      }
  29. }
  30.